<!DOCTYPE html>
<html>

<head>
    <title>攻略收藏</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/common.js"></script>


</head>

<body>

<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left" ></i></span>
            </a>
        </div>
        <div class="col">
            <span>攻略收藏</span>
        </div>
        <div class="col"></div>
    </div>
</div>
<br><br>

<div class="container strategyCollect">
    <div class="row hot" render-loop="list">
        <div class="col-4">
            <a href="/strategyCatalogs.html?id=" render-fun="setHref" render-key="list.id">
                <img render-src="list.coverUrl" style="width: 90%">
                <p render-html="list.title"></p>
            </a>
            <i class="fa fa-trash deleteCollectBtn" style="color: mediumvioletred"></i>
            <input type="hidden" render-value="list.id"/>
        </div>
    </div>
</div>


<script>
    var userStr = sessionStorage.getItem("user");
    var user;
    if (userStr) {
        user = JSON.parse(userStr);
        $("#userId").val(user.id);
    }

    var strategyId;
    $.get("/strategies/strategyCollect",{"userId":user.id},function (data) {
        $(".strategyCollect").renderValues({"list":data},{
            setHref:setHref
        })


        $(".deleteCollectBtn").click(function () {
            strategyId = $(this).next("input").val();
            $(document).dialog({
                type: 'confirm',
                closeBtnShow: true,
                content: '确认删除吗 ~',
                onClickConfirmBtn: function () {
                    $.ajax({
                        type: "DELETE",
                        url: "/strategies/" + user.id,
                        data: {"strategyId": strategyId},
                        success: function (data) {
                            location.reload();
                        }

                    })
                }
            })
        });

    })






</script>

</body>

</html>